package com.yishe.controller.ys;

import com.google.common.collect.ImmutableMap;
import com.yishe.biz.mysql.YsStaffBiz;
import com.yishe.biz.mysql.YsStaffCaseBiz;
import com.yishe.biz.tech.TechBiz;
import com.yishe.biz.ys.YsBiz;
import com.yishe.config.ObjectRestResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author : chusifeng
 * @version :
 * @date :Create in 2021/4/26 10:56
 * @description: 通用
 * @package com.yishe.controller.ys
 * @className YsController
 */
@RestController
@Slf4j
@RequestMapping(value = "/ys")
public class YsController {

    @Resource
    private YsBiz ysBiz;
    @Resource
    private TechBiz techBiz;

    /**
     * 根据课程号获取已分配老师
     * @param caseNo
     * @return
     */
    @RequestMapping(value = "getStaffListByCaseNo",method = RequestMethod.GET)
    public ObjectRestResponse getStaffListByCaseNo(@RequestParam("caseNo") String caseNo){
        ObjectRestResponse restResponse = new ObjectRestResponse();
        try {
            restResponse.setData(techBiz.getYsStatffCaseListByParam(ImmutableMap.of("caseNo",caseNo)));
        } catch (Exception e) {
            log.error("根据课程号查询所有課程已分配的老師出錯！",e);
            restResponse.setErrorMsg("根据课程号查询課程已分配的老師");
        }
        return restResponse;
    }

    /**
     * 根据课程类型号获取课程类型配置信息
     * @param caseType
     * @return
     */
    @RequestMapping(value = "getCaseTypeByNo",method = RequestMethod.GET)
    public ObjectRestResponse getCaseTypeByNo(@RequestParam("caseType") String caseType){
        ObjectRestResponse restResponse = new ObjectRestResponse();
        try {
            restResponse.setData(ysBiz.getCaseTypeByCaseType(caseType));
        } catch (Exception e) {
           log.error("根据课程类型获取课程类型信息出错{}，错误是{}",caseType,e);
        }
        return restResponse;
    }

    /**
     * 根据课程号获取课程信息
     * @param caseNo
     * @return
     */
    @RequestMapping(value = "getCaseDetailByNo",method = RequestMethod.GET)
    public ObjectRestResponse getCaseDetailByNo(@RequestParam("caseNo") String caseNo){
        ObjectRestResponse restResponse = new ObjectRestResponse();
        try {
            restResponse.setData(ysBiz.getCaseInfoByCaseNo(caseNo));
        } catch (Exception e) {
            restResponse.setErrorMsg("根据课程号获取课程信息出错！");
            log.error("根据课程号获取课程信息出错,{},错误信息是{}",caseNo,e);
        }
        return restResponse;
    }
}
